package backlet;

import java.util.HashMap;
import java.util.Map;

import util.ByteBuffer;


/**逻辑处理类
 * @author Administrator
 *
 */
public abstract class Backlet
{
	public static int num;
	public Map<Integer,LogicHandler> handlers = new HashMap<Integer, LogicHandler>();
	
	public Backlet()
    {
		init();
    }
	
	public abstract void init();
	
	public void addHandler(int id,LogicHandler handler)
    {
		handlers.put(id, handler);
    }

	public void deal(ByteBuffer data, int sessionId)
    {
		int id = data.readInt();
		LogicHandler handler = handlers.get(id);
		if(handler == null)
		{
			System.err.println("收到错误handler编号： "+id);
		}else
		handler.deal(data,sessionId);
    }
}
